/*
 * @Author: 刘苗
 * @Description: 
 * @Date: 2021-08-24 15:53:43
 */
import Vue from "vue";
import "normalize.css/normalize.css";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "@/styles/index.scss";
import App from "./App";
import store from "./store";
import router from "./router";
import "@/icons";
// import "@/permission";
import i18n from "@/lib/lang/index";

import "@/directive";

import FullCalendar from 'vue-fullcalendar'
Vue.use(FullCalendar)

// http请求挂载全局
import api from "@/api";
Object.keys(api).forEach(key => {
  Vue.prototype["$" + key] = api[key];
});

import mavonEditor from "mavon-editor";
import "mavon-editor/dist/css/index.css";
Vue.use(mavonEditor);

import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
Vue.use(VXETable)


// 语言
let language = window.localStorage.getItem("language");
var locale = null;
if (language) {
  if (language == "en") {
    locale = require("element-ui/lib/locale/lang/en").default;
    i18n.locale = "en";
  } else if (language == "zh") {
    locale = require("element-ui/lib/locale/lang/zh-CN").default;
    i18n.locale = "zh";
  } else {
    locale = require("element-ui/lib/locale/lang/ko").default;
    i18n.locale = "ko";
  }
} else {
  locale = require("element-ui/lib/locale/lang/zh-CN").default;
  i18n.locale = "zh";
}


// 自动化
let Modules = [
  require.context("./components/table", true, /\.vue$/),
  require.context("./components/input", true, /\.vue$/),
  require.context("./components/select", true, /\.vue$/),
  require.context("./components/dialog", true, /\.vue$/),
  require.context("./components/date", true, /\.vue$/),
  require.context("./components/form", true, /\.vue$/)
];
Modules.forEach(el => {
  el.keys().forEach(fileName => {
    const componentConfig = el(fileName);
    const componentName = fileName.replace(/^\.\//, "").replace(/\.vue$/, "");
    const component = Vue.component(
      componentName.replace(/\//, "-"),
      componentConfig.default || componentConfig
    );
  });
});

Vue.use(ElementUI, { locale });
Vue.config.productionTip = false;

new Vue({
  el: "#app",
  i18n,
  router,
  store,
  render: h => h(App)
});
